<!DOCTYPE>
<html>
<head>
	<script src="https://github.com/typicaljoe/taffydb/raw/master/taffy.js"></script>
	<script type="text/javascript">
		// create database in-memory
		var db = TAFFY();
	
		if (window.XMLHttpRequest) {
			xhttp=new XMLHttpRequest();
		} else {
			xhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
//	    xhttp.open("GET","http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml",true);
	    xhttp.open("GET","../xml/eurofxref-hist-90d.xml", false);
	    xhttp.send();
	    xmlDoc=xhttp.responseXML;
	    //x= xmlDoc.documentElement.getElementsByTagName("gesmes:Envelope");
	    x= xmlDoc.childNodes;

	    for(i=0; i<x.length; i++){
	    	xx = x[i].childNodes;
	    	
	    	for(j=0; j<xx.length; j++){
				if(xx[j].nodeName=="Cube"){
					xxx = xx[j].childNodes;
					
					for(h=0; h<xxx.length; h++){
						xxxx = xxx[h].childNodes;
						try {
						    var dateday = xxx[h].getAttribute('time');

							for(k=0; k < xxxx.length; k++){
								var currency = xxxx[k].getAttribute('currency');
								var rate = xxxx[k].getAttribute('rate');
								//console.log(dateday + currency + rate);
								db.insert({date: dateday, currency: currency, rate: rate});

							}
						} catch (e) {
						    // console.log(xxx[h].nodeName);
						}
					}
				}
			}
		}
		// show each row
		// db().each(function (r) {alert(r.date + r.currency + r.rate);});


//	    for(i=0;i<largo;i++){
//		    var aux = x[i].getElementsByTagName("Cube")[0].getAttribute('time');
		    
		    //nombre = aux[0].firstChild.nodeName;
		    //var aux = x[i].getElementsByTagName("Cube")[0].getAttribute('time');
		    //var circulation = aux.getElementsByTagName("Cube")[0].getAttribute('time');
			
//			console.log(aux);
//		}
	</script>
</head>
<body>
</body>
</html>